﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace LabMS.Web.User
{
    public partial class ChooseTeacherRealName : Base.BasePage
    {
        LabMS.BLL.Staff BT = new LabMS.BLL.Staff();
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("YHGL");
            strPageUserType.Add("mana");
            if (!IsPostBack)
            {
                InitBind("1=1");
            }
        }

        protected void InitBind(string str)
        {
            DataSet ds=new DataSet();
            ds = BT.GetList(str);
            gvT.DataSource=ds.Tables[0].DefaultView;
            gvT.DataBind();
        }

        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnsercher_Click(object sender, EventArgs e)
        {
            string sql = "1=1";
            if (!string.IsNullOrEmpty(tbTcode.Text.Trim()))
            {
                sql = "Staff_Code like '%" + tbTcode.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(tbTname.Text.Trim()))
            {
                sql += " and Staff_Name like '%" + tbTname.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(tbTP.Text.Trim()))
            {
                sql += " and Staff_Title like '%" + tbTP.Text.Trim() + "%'";
            }
            InitBind(sql);
        }
        /// <summary>
        /// 重置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnreset_Click(object sender, EventArgs e)
        {
            tbTcode.Text = "";
            tbTname.Text = "";
            InitBind("1=1");
        }

        protected void gvT_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[1].Text + "','"+e.Row.Cells[3].Text+"')");
                e.Row.Attributes["style"] = "Cursor:pointer";
            }
        }

        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvT_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvT.PageIndex = e.NewPageIndex;
            InitBind("1=1");
        }
    }
}
